import jdk.nashorn.internal.objects.Global;
import org.junit.Test;
import org.junit.runner.Runner;

/**
 * @author jcl_hqu
 * @date 2021/3/17 21:54
 */
public class MyThread extends Thread{

    public static void main(String args[]){

        ShareData task=new ShareData(); //共享数据类
        MyThread myThread1=new MyThread(){
            @Override
            public void run() {
                super.run();
                try {
                    task.produce("生产者");
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        };
        MyThread myThread2=new MyThread(){
            @Override
            public void run() {
                super.run();
                try {
                    task.consume("消费者");
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        };
        myThread2.start();
        myThread1.start();
    }
}
